/*
 * cudanTextureMemory.h
 *
 *  Created on: Dec 9, 2009
 *      Author: daniel
 */

#ifndef CUDANTEXTUREMEMORY_H_
#define CUDANTEXTUREMEMORY_H_

#include "cudanDeviceMemory.h"
#include "cudanCudaArrayMemory.h"

namespace CUDAN
{
	template<typename T, int D>
	class TextureMemory : public DeviceMemory<T,D>
	{
	public:
		CudaArrayMemory<T,D> cudaArray;
		texture<T,D, cudaReadModeElementType>* texref;

	public:
		TextureMemory();
		TextureMemory(HostMemory<T,D>*);
		TextureMemory(DeviceMemory<T,D>*);
		TextureMemory(CudaArrayMemory<T,D>*);
		TextureMemory(TextureMemory<T,D>*);
		TextureMemory<T,D>* operator=(HostMemory<T,D>*);
		TextureMemory<T,D>* operator=(DeviceMemory<T,D>*);
		TextureMemory<T,D>* operator=(CudaArrayMemory<T,D>*);
		TextureMemory<T,D>* operator=(TextureMemory<T,D>*);
		virtual ~TextureMemory();

	public:
		virtual bool bind(texture<T, D, cudaReadModeElementType>*);
		virtual void freeMemory();
		virtual void print();
		virtual void print(DimensionSizeVector&);
		virtual bool allocateMemory(DimensionSizeVector&);
		virtual bool copyFrom(HostMemory<T,D>*);
		virtual bool copyFrom(DeviceMemory<T,D>*);
		virtual bool copyFrom(CudaArrayMemory<T,D>*);
		virtual bool copyFrom(TextureMemory<T,D>*);
		virtual bool copyTo(HostMemory<T,D>*);
		virtual bool copyTo(DeviceMemory<T,D>*);
		virtual bool copyTo(CudaArrayMemory<T,D>*);
		virtual bool copyTo(TextureMemory<T,D>*);
	};
}

#include "cudanTextureMemory.cpp"

#endif /* CUDAFWTEXTUREMEMORY_H_ */
